package site.brood.log.controller;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.brood.common.core.web.AjaxJson;
import site.brood.common.log.pojo.LogOperationDto;
import site.brood.common.security.annotation.InnerAuth;
import site.brood.log.entity.LogOperation;
import site.brood.log.service.LogOperationService;

/**
 * 操作日志记录
 */
@RestController
@RequestMapping("/operlog")
public class OperationLogController {

    @Autowired
    private LogOperationService logOperationService;

    @InnerAuth
    @PostMapping("/add")
    public AjaxJson add(@RequestBody LogOperationDto operLog)
    {
        LogOperation logOperation = new LogOperation();
        BeanUtils.copyProperties(logOperation,operLog);
        return AjaxJson.success(logOperationService.saveOrUpdate(logOperation));
    }
}
